import formItem from "../uni_modules/uview-ui/libs/config/props/formItem.js";
import request from "../utils/request.js"
export default {
	namespaced: true,
	state: {
		ma_fault_class: [],
		ma_fault_code: [],
		ma_solute_code: [],
		repair_type: []
	},

	mutations: {
		getFaultClass(state, faultClass) {
			if (state.ma_fault_class.length) {
				state.ma_fault_class.length = 0
			}
			for (let i in faultClass) {
				state.ma_fault_class.push(faultClass[i].dictLabel);
			}
		},
		getFaultCode(state, faultCode) {
			if (state.ma_fault_code) {
				state.ma_fault_code.length = 0
			}
			for (let i in faultCode) {
				state.ma_fault_code.push(faultCode[i].dictLabel);
			}
		},
		getSoluteCode(state, soluteCode) {
			if (state.ma_solute_code) {
				state.ma_solute_code.length = 0
			}
			for (let i in soluteCode) {
				state.ma_solute_code.push(soluteCode[i].dictLabel);
			}
		},
		getRepairType(state, repairType) {
			if (state.repair_type) {
				state.repair_type.length = 0
			}
			for (let i in repairType) {
				state.repair_type.push(repairType[i].dictLabel);
			}
		}
	},
	actions: {

		async setFaultClass({
			commit
		}) {
			console.log("运行了");
			const res = await request({
				url: 'prod-api/system/dict/data/type/ma_fault_class'
			})
			commit('getFaultClass', res.data)
		},
		async setFaultCode({
			commit
		}) {
			const res = await request({
				url: 'prod-api/system/dict/data/type/ma_fault_code'
			})
			commit('getFaultCode', res.data)
		},
		async setSoluteCode({
			commit
		}) {
			const res = await request({
				url: 'prod-api/system/dict/data/type/ma_solute_code'
			})
			commit('getSoluteCode', res.data)
		},
		async setRepairType({
			commit
		}) {
			const res = await request({
				url: 'prod-api/system/dict/data/type/repair_type'
			})
			console.log('11111',res);
			commit('getRepairType', res.data)
		}
	},


}
